import http from '../../assets/js/http'
const state = {
  wxConfig: {}, // 微信分享配置
  circleTotal: 0, // 组织总个数
  searchCircleText: '',
  myPublicInfo: {},
  activityDetail: null,
  actCollectActivityDetail: null,
  createGroupForm: null,
  actCollectCreateGroupForm: null,
  cardInfo: null, // 编辑的名片信息
  cardInfoWords: ''// 附言
}

// getters
const getters = {

}

// actions
const actions = {

  getActivityDetail ({ commit, state }, config) {
    return new Promise((resolve, reject) => {
      http.post('/api/greengage/alumni/activityDetail', config).then((res) => {
        if (res.code === 200) {
          commit('setActivityDetail', res.data)
        }
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  getActCollectActivityDetail ({ commit, state }, config) {
    return new Promise((resolve, reject) => {
      http.post('/api/greengage/activityGroup/activityDetail', config).then((res) => {
        if (res.code === 200) {
          commit('setActCollectActivityDetail', res.data)
        }
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
}

// mutations
const mutations = {
  setCircleTotal (state, total) {
    state.circleTotal = total
  },
  setSearchCircleText (state, text) {
    state.searchCircleText = text
  },
  setMyPublicInfo (state, info) {
    state.myPublicInfo = info
  },
  setActivityDetail (state, info) {
    state.activityDetail = info
  },
  setActCollectActivityDetail (state, info) {
    state.actCollectActivityDetail = info
  },
  setCreateGroup (state, info) {
    state.createGroupForm = info
  },
  setActCollectCreateGroup (state, info) {
    state.actCollectCreateGroupForm = info
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
